<?php

$altNames = $model->altNames;
?><h2>其它名称</h2>
<?php
if (count($altNames) > 0) {
	$this
		->widget('zii.widgets.grid.CGridView',
			array(
				'id' => 'material-alt-name-grid',
				'dataProvider' => new CArrayDataProvider($altNames,
					array(
						'pagination' => false
					)),
				'enablePagination' => false,
				'template' => "{items}",
				'columns' => array(
					array(
						'name' => 'name',
						'header' => '名称'
					),
					array(
						'class' => 'CButtonColumn',
						'template' => Yii::app()->user->checkAccess('materialManage') ? '{delete}'
							: '',
						'deleteButtonUrl' => 'Yii::app()->controller->createUrl("deleteAltName",array("id"=>$data->primaryKey))'
					),
				),
			));
} else {
?>
	<div>无</div>
	<?php
	}
	if (Yii::app()->user->checkAccess('materialManage')) {
	?>
		<div id="material-alt-name-add" class="form">
		<h2>添加其它名称</h2>
		<?php
			$altNameModel = new MaterialAltName();
			$altNameModel->materialId = $model->id;
			$form = $this
				->beginWidget('CActiveForm',
					array(
						'action' => array(
							'material/createAltName'
						),
						'id' => 'material-alt-name-form',
						'enableAjaxValidation' => false,
					));
		?>
			<div class="row">
				<?php echo $form->labelEx($altNameModel, 'name'); ?>
				<?php echo $form
						->textField($altNameModel, 'name',
							array(
								'size' => 6,
								'maxlength' => 255
							));
					echo $form->hiddenField($altNameModel, 'materialId');
				?>
				<?php echo $form->error($altNameModel, 'name'); ?>
			</div>
		
			<div class="row buttons">
				<?php echo CHtml::submitButton('添加'); ?>
			</div>
		<?php $this->endWidget(); ?>
		</div>
		
		<?php
		}

		?>
